﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="adminProgramClass.aspx.cs" Inherits="Admin_adminProgramClass" %>
<%@ Register Src="adminfoot.ascx" TagName="adminfoot" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>项目类别管理</title>
    <link rel="stylesheet" href="imgs/admin.css" type="text/css" media="all" />
    <script type="text/javascript" src="../DotNet_net/js/jquery-1.3.2.min.js"></script>
     <script type="text/javascript" src="imgs/GetAjax.js"></script>
    <script type="text/javascript" src="../DotNet_net/js/common.js"></script>
</head>
<body onload="$('#loading').hide()">
<form id="form1" runat="server">   
<div class="container" id="cpcontainer">    
 <div id="loading" style="display:block">   
    <div class="loading-indicator">   
        页面正在加载中...   
    </div>   
</div>  
        <table class="tb2">
        <tr class="thead"><th colspan="7">
            项目分类管理(<font color='red'>＊</font>为必填,其它选填)</th></tr>	
        <tr align="center">
			<td align="left" style="width: 21%; height: 18px">
                ID.分类名称(项目数量)</td>
			<td style="width: 21%; height: 18px">类别名</td>
            <td style="width: 18%; height: 18px">类别简述</td>
			<td style="width: 11%; height: 18px">排序</td>
			<td style="height: 18px">&nbsp;操作</td>		
        </tr>    
        <%=bindProgramClassList(0,0,new StringBuilder()) %>  
        </table>
        
   <table class="tb" id="tbS"><tr><td style="height: 38px"><div style="width:90%; float:left;">全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(this.checked,'m_id')" />反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onclick="checkOthers('m_id')" />
   <input type="button" value="批量修改选中分类" class="btn" onclick="doPostEdit('','m_id')" id="Button1"/>&nbsp;&nbsp;&nbsp;移动到
   <select id="yidong">
       <%=programClassDp()%>
   </select><input type="button" value="批量移动分类" name="button" class="btn" onclick="doPostMove('','m_id');"/></div> <div style="width:10%; float:right;"><input type="button" value="批量删除" onclick="doPostDeletes('','m_id')" class="btn" style="color:Red;"  /></div>
   </td></tr></table>
    <table class="tb mt20" id="insertTb">
    <tr class="thead"><th colspan="8" id="add_pc">
        添加/编辑分类</th></tr>	
        <tr align="center">
            <td width="305" align=left>
            选择层级：
                <select id="insert">
                    <%=programClassDp()%>
                </select>
                <input id="pcid_hid" name="pcid_hid" runat="server" type="hidden" /></td>
            <td  width="253">类别名
              <input type="text" name="m_pcname" id="m_pcname" runat="server" style="width: 200px" ><font color='red'>＊</font></td>
            <td  width="207">类别简述
              <input type="text" name="m_pcTag" id="m_pcTag" runat="server" style="width: 200px"></td>
            <td width="136">排序
              <input size="3" type="text" name="m_pcsort" id="m_pcsort" runat="server"><font color='red'>＊</font></td>
            <td width="175">
        <input type="button" value="确认提交" class="btn"  onclick="doPostInsert('')"/>
                &nbsp;&nbsp;
                <input id="Button2" onclick="javascript:location.href=location.href" class="btn" type="button" value="清空" /></td>
    </tr>
        <tr align="center">
            <td align="left" colspan="5">
                &nbsp;<img align="absMiddle" class="pointer" onclick="$('#seo').stop().toggle()"
                    src="imgs/btn_add.gif" />
                &nbsp;<font color="red">项目优化</font></td>
        </tr>
        <tr align="center">
            <td align="left" colspan="5" id="seotd">
                <table id="seo" style="display: none" width="100%">
                    <tr>
                        <td align="right" style="height: 31px; width: 102px;">
                            标题：</td>
                        <td style="height: 31px">
                            <input id="programTitle" name="programTitle" style="width: 200px" runat="server" />&nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td align="right" style="height: 31px; width: 102px;">
                            关键字：</td>
                        <td style="height: 31px">
                            <input id="programKey" name="programKey" style="width: 200px" type="text" runat="server" /></td>
                    </tr>
                    <tr>
                        <td align="right" style="width: 102px; height: 124px">
                            描述：</td>
                        <td>
                            &nbsp;<textarea id="programDescription" name="programDescription" style="width: 357px;
                                height: 150px" runat="server"></textarea></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr align="center">
            <td align="left" width="305">
            </td>
            <td width="253">
            </td>
            <td width="207">
            </td>
            <td width="136">
            </td>
            <td width="175">
            </td>
        </tr>
</table>
 <uc1:adminfoot ID="Adminfoot1" runat="server" />
    </div>  
<script language="javascript" type="text/javascript">
 function  doPostDeletes(url,sname)
    {   
        var ids=getIDList(sname);
        if(ids!="")
        {
            if((confirm("确定要删除这些记录?"))==true)
            { $("#loading").show();
                url=convertURL(url+"?action=delAll&id="+ids);
//                location.href=url
                $("#loading").show();
                ajax_get(url,'',function(msg)
                {
                    $("#cpcontainer").empty().append(msg);
                    $("#loading").hide();
                });
	        }
	    }
	    else
	    {
	        alert("您还没有选择要删除的项");	      
	        return false;
	    }
    }

function doPostInsert(url)
{
    $("#loading").show();
    var Datalist='';
    var pid="";
    pid=document.getElementById("insert").options[document.getElementById("insert").selectedIndex].value;
    var programId=$("#pcid_hid").attr("value");   
    if(!isNaN(programId)&&programId!="")
    {
        url=url+"?action=update&id="+pid+"&programid="+programId;
    }
    else
    {
        url=url+"?action=Insert&id="+pid;
    }  
    Datalist+= "&pcname="+$("input[name=m_pcname]").attr("value")+
               "&pcTag="+$("input[name=m_pcTag]").attr("value")+   
                "&programTitle="+$("#programTitle").attr("value")+
                "&programKey="+$("#programKey").attr("value")+
                "&programDescription="+$("#programDescription").attr("value")+            
               "&pcsort="+$("input[name=m_pcsort]").attr("value");
               $("#loading").show();
     ajax_post(url,Datalist,function(msg)
     {
        if(msg==1)
        {
            alert("排序不能为空！");
        }
        else if(msg==2)
        {
            alert("类别名称不能为空！");
        }
        else
        {
             $("#cpcontainer").empty().append(msg);
        }        
        $("#loading").hide();  
   })
}

 function  doPostEdit(url,sname)
    {    
       
        var ids=getIDList(sname);
        var Param='';
        if(ids!="")
        {
            if((confirm("确定要批量修改这些记录?"))==true)
            { 
                  $("#loading").show();
                  url=url+"?action=editAll&id="+ids;         
                  for(var i=0;i<=ids.split(',').length-1;i++)
                  { 
                     
                     var id=ids.split(',')[i];
                     Param+= "&pcname"+id+"="+$("#pcname"+id).attr("value")+
                             "&pcTag"+id+"="+$("#pcTag"+id).attr("value")+
                             "&pcsort"+id+"="+$("#isSort"+id).attr("value")+
                             "&programTitle"+id+"="+$("#programTitle"+id).attr("value")+
                            "&programKey"+id+"="+$("#programKey"+id).attr("value")+
                            "&programDescription"+id+"="+$("#programDescription"+id).attr("value")+  
                            "&pFid"+id+"="+$("#pFid"+id).attr("value");                  
                  }                 
                  $("#loading").show();
                    ajax_post(url,Param,function(msg){
                    if(msg==1)
                    {
                        alert("排序必须为数字！");
                    }
                    else if(msg==2)
                    {
                        alert("类别名不能为空！");
                    }
                    else
                    {
                        $("#cpcontainer").empty().append(msg);
                    } 
                    $("#loading").hide();
                 });
	        }
	    }
	    else
	    {
	        alert("您还没有选择要修改的项");	      
	        return;
	    }
    }
function doPostMove(url,sname)
{
 
    var ids=getIDList(sname);
    if(ids!="")
    {
        var yidong="";
        var Param="";
        yidong=document.getElementById("yidong").options[document.getElementById("yidong").selectedIndex].value;
        if((confirm("确定要移动这些记录?"))==true)
        {   $("#loading").show();
            url=convertURL(url+"?action=MoveAll&id="+yidong+"&pcid="+ids);
           $("#loading").show();
            ajax_get(url,'',function(msg)
            {
                $("#cpcontainer").empty().append(msg);
                $("#loading").hide();
            });
        }
    }
    else
    {
        alert("您还没有选择移动项");	       
        return false;
    }
}
function edit(pcid)
{
    $("#loading").show();
    var url="adminProgramClass.aspx?action=edit&id="+pcid;
    ajax_get(url,'',function(msg)
    {
        $("#cpcontainer").empty().append(msg);
        $("#loading").hide();        
    });
}
</script>
</form>
</body>

</html>
